﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;

namespace CYTS.Aoyou.Framework.Log
{
    /// <summary>
    /// 通用日志记录者
    /// </summary>
    public class CommonLogger : Logger
    {
        /// <summary>
        /// 记录错误
        /// </summary>
        /// <param name="message"></param>
        /// <param name="ex"></param>
        public static void LogError(object message, Exception ex)
        {
            string currentLoggerName = message.GetType().FullName + "Logger";
            ICommonLog logger = GetLogger<ICommonLog>(currentLoggerName);
            if (logger.IsErrorEnabled)
            {
                logger.Error(message, ex);
            }
        }

        /// <summary>
        /// 记录信息
        /// </summary>
        /// <param name="message"></param>
        public static void LogInfo(object message)
        {
            string currentLoggerName = message.GetType().FullName + "Logger";
            ICommonLog logger = GetLogger<ICommonLog>(currentLoggerName);
            if (logger.IsInfoEnabled)
            {
                logger.Info(message);
            }
        }


    }    
}
